package com.gxa.clientadmin.service.impl;

/*
 *
 *@author leijun
 *
 *@creating 2020/11/16 11:26
 *
 */

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gxa.clientadmin.mapper.LogsMapper;
import com.gxa.clientadmin.pojo.Logs;
import com.gxa.clientadmin.service.LogsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName LogsServiceImpl
 * @Description TODO
 * @Author 俊
 * @Date 2020/11/16 11:26
 * @Version 1.0
 */
@Service("logsService")
public class LogsServiceImpl implements LogsService {
    @Resource
    LogsMapper logsMapper;

    @Override
    public Integer add(Logs logs) {
        logs.setDate(new Date());
        return logsMapper.insertSelective(logs);
    }

    @Override
    public Map log(Integer id, Integer page, Integer limit) {
        HashMap<String, Object> map = new HashMap<>();
        PageHelper.startPage(page,limit);
        List<Logs> logs = (List<Logs>) logsMapper.selectByPrimaryKey(id);
        PageInfo<Logs> info = new PageInfo<>(logs);
        map.put("list",info.getList());
        map.put("count",info.getTotal());
        return map;

    }

    @Override
    public Map logs(Integer page, Integer limit) {
        HashMap<String, Object> map = new HashMap<>();
        PageHelper.startPage(page,limit);
        List<Logs> logs = logsMapper.selectAll();
        PageInfo<Logs> info = new PageInfo<>(logs);
        map.put("list",info.getList());
        map.put("count",info.getTotal());
        return map;
    }
}
